function isValid(s: string): boolean {
  if (s.length % 2) {
    return false
  }
  const map = new Map()
  map.set('{', '}')
  map.set('[', ']')
  map.set('(', ')')
  let stack: string[] = []
  for (let i = 0; i < s.length; i++) {
    if (map.has(s[i])) {
      stack.push(s[i])
    } else {
      if (stack.length === 0) {
        return false
      }
      const s1 = stack.pop()
      if (map.get(s1) !== s[i]) {
        return false
      }
    }
  }
  return stack.length === 0
}
